@attribute [Route(PageUrls.NotAuthorized)]
@attribute [Route("{culture?}" + PageUrls.NotAuthorized)]
@inherits AppPageBase

<AppPageData Title="@Localizer[nameof(AppStrings.NotAuthorizedPageTitle)]" />

@if (isUpdatingAuthState)
{
    <LoadingComponent />
}
else
{
    <AuthorizeView>
        <Authorized>
            <section>
                <BitStack HorizontalAlign="BitAlignment.Center">
                    <BitImage Src="_content/Boilerplate.Client.Core/images/403.svg" Width="100%" Style="max-width:600px" />

                    <BitText Typography="BitTypography.H5" Color="BitColor.SevereWarning" Align="BitTextAlign.Center">
                        @Localizer[nameof(AppStrings.ForbiddenException)]
                    </BitText>

                    <BitText>@Localizer[nameof(AppStrings.YouAreSignedInAs)] <b>@context.User.GetDisplayName()</b></BitText>

                    @if (lacksValidPrivilege)
                    {
                        <BitButton Style="width:300px"
                                   Color="BitColor.SevereWarning"
                                   Href="@($"{PageUrls.Settings}/{PageUrls.SettingsSections.Sessions}")">
                            @Localizer[nameof(AppStrings.TryRemovingOtherSessions)]
                        </BitButton>
                    }

                    <BitButton AutoLoading
                               Style="width:300px"
                               OnClick="WrapHandled(SignIn)">
                        @Localizer[nameof(AppStrings.SignInAsDifferentUser)]
                    </BitButton>

                </BitStack>
            </section>
        </Authorized>
        <NotAuthorized>
            <section>
                <BitStack Alignment="BitAlignment.Center">
                    <BitImage Src="_content/Boilerplate.Client.Core/images/401.svg" Width="100%" Style="max-width:600px" />
                    <BitText Typography="BitTypography.H3" Align="BitTextAlign.Center">
                        @Localizer[nameof(AppStrings.YouAreNotAuthorized)]
                    </BitText>
                    <BitText Typography="BitTypography.Subtitle1" Align="BitTextAlign.Center" Gutter>
                        @Localizer[nameof(AppStrings.YouAreNotAuthorizedMessage)]
                    </BitText>
                    <BitButton AutoLoading
                               Variant="BitVariant.Outline"
                               OnClick="WrapHandled(SignIn)"
                               IconName="@BitIconName.Signin">
                        @Localizer[nameof(AppStrings.SignIn)]
                    </BitButton>
                </BitStack>
            </section>
            <!-- Alternatively, you can redirect the user to the sign-in page. -->
            @* <RedirectToSignInPage ReturnUrl="@ReturnUrl" /> *@
        </NotAuthorized>
    </AuthorizeView>
}